﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Qiang.Geometry
{
    public abstract class Curve : Geometry, ICurve
    {
        #region 初始化

        public Curve()
        { }

        public Curve(IList<Coordinate> coordinates)
        {
 
        }

        public Curve(Coordinate startPoint, Coordinate endPoint)
        {
            _startPoint = startPoint;
            _endPoint = endPoint;
        }

        #endregion


        #region IPoint成员


        Coordinate _startPoint;

        /// <summary>
        /// 起始点。
        /// </summary>
        public Coordinate StartPoint
        {
            get { return _startPoint; }
            set { _startPoint = value; }
        }


        Coordinate _endPoint;

        /// <summary>
        /// 结束点。
        /// </summary>
        public Coordinate EndPoint
        {
            get { return _endPoint; }
            set { _endPoint = value; }
        }

              
        /// <summary>
        /// 曲线长度。
        /// </summary>
        public double Length
        {
            get { return ComputeLength(); }            
        }


        bool _isClosed;

        /// <summary>
        /// 是否封闭。
        /// </summary>
        public virtual bool IsClosed
        {
            get { return _isClosed; }
        }

        /// <summary>
        /// 是否是环。
        /// </summary>
        public abstract bool IsRing { get; }



        #endregion


        #region Geometry成员

        /// <summary>
        /// 
        /// </summary>
        public override GeometryType GeometryType
        {
            get { return Qiang.Geometry.GeometryType.Curve; }
        }

        #endregion


        #region 方法

        /// <summary>
        /// 计算曲线长度。
        /// </summary>
        /// <returns></returns>
        protected virtual double ComputeLength()
        {
            return 0;
        }


        #endregion


    }
}
